import 'package:flutter/material.dart';
import 'package:flutter04/controller/list_controller.dart';
import 'package:flutter04/pages/form.dart';
import 'package:get/get.dart';

class CategoryPage extends StatefulWidget {
  const CategoryPage({super.key});

  @override
  State<CategoryPage> createState() => _CategoryPageState();
}

class _CategoryPageState extends State<CategoryPage> {
  ListController listController = Get.find<ListController>();

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Obx(() => Text("当前计数：${listController.count.value}")),
          ElevatedButton(
            onPressed: () {
              listController.increment();
            },
            child: const Text("+1"),
          ),
          ElevatedButton(
            onPressed: () {
              Get.toNamed("/search");
            },
            child: const Text("搜索"),
          ),
          const SizedBox(
            height: 20,
          ),
          ElevatedButton(
            onPressed: () {
              Navigator.of(context).push(
                MaterialPageRoute(builder: (BuildContext context) {
                  return const FormPage();
                }),
              );
            },
            child: const Text("表单"),
          ),
        ],
      ),
    );
  }
}
